package com.heaven.map.handler;

import com.heaven.map.pojo.vo.ResponseInfo;
import com.heaven.map.utils.CodeEnum;
import org.apache.shiro.authc.IncorrectCredentialsException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class GlobalExceptionHandler {

    private static final Logger log = LoggerFactory.getLogger(GlobalExceptionHandler.class);

    @ExceptionHandler(IncorrectCredentialsException.class)
    public ResponseInfo tokenException(IncorrectCredentialsException incorrectCredentialsException){
        log.debug("输出信息", incorrectCredentialsException);
        ResponseInfo responseInfo = new ResponseInfo(null,incorrectCredentialsException.getMessage(), CodeEnum.Unauthorized.getCode());
        return  responseInfo;
    }
}
